
function checkWidgetEcho(widgetid,tbname,clmname,vl,noteqid,alertmsgname)
{
    if(widgetid!=""&&tbname!=""&&clmname!=""&&vl!=""&&noteqid!=="")
    {
        $.ajax({
            url:'api.php?method=checkWidgetEcho',
            type:'POST', //GET
            data:{
                tbname:tbname,
                clmname:clmname,
                vl:vl,
                noteqid:noteqid
            },
            async:true,    //或false,是否异步
            timeout:5000,    //超时时间
            dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
            beforeSend:function(xhr){
                console.log(xhr)
                console.log('发送前')
            },
            success:function(data,textStatus,jqXHR){
                //alert(data.name);
                if(data.return_code!="0")
                {
                    bootbox.alert(alertmsgname+"已存在，请重新填写",function () {
                        $("#"+widgetid).val("");
                    })
                }



            },
            error:function(xhr,textStatus){
                console.log('错误')
                console.log(xhr)
                console.log(textStatus)
            },
            complete:function(){
                console.log('结束')
            }
        });
    }


}

function resetUPwd(uid)
{
    bootbox.prompt("<font color='red'>确定要重置此用户的密码吗？请在下方输入重置后的密码</font>",function (result) {
        if(result==null)return;
        if(result!="")
        {
            $.ajax({
                url:'api.php?method=resetUPwd',
                type:'POST', //GET
                async:true,    //或false,是否异步
                data:{
                    id:uid,
                    np:result
                },
                timeout:5000,    //超时时间
                dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                beforeSend:function(xhr){
                    console.log(xhr)
                    console.log('发送前')
                },
                success:function(data,textStatus,jqXHR){
                    //alert(data.name);
                    if(data.return_code=="0")
                    {

                        bootbox.alert("重置成功",function () {

                            $("#userTable").bootstrapTable('refresh',{'url':tableurl});
                        });
                    }
                    else
                    {
                        bootbox.alert("重置失败");
                    }



                },
                error:function(xhr,textStatus){
                    console.log('错误')
                    console.log(xhr)
                    console.log(textStatus)
                },
                complete:function(){
                    console.log('结束')
                }
            });
        }
    })
}

function changepwd(uid)
{
    bootbox.dialog({
        title : "修改密码",
        message : "<div class='well ' style='margin-top:25px;'><form class='form-horizontal' role='form'><div class='form-group'><label class='col-sm-3 control-label no-padding-right' for='txtOldPwd'>旧密码</label><div class='col-sm-9'><input type='text' onfocus=\"this.type='password'\" id='txtOldPwd' placeholder='请输入旧密码' class='col-xs-10 col-sm-5' autocomplete='off'/></div></div><div class='space-4'></div><div class='form-group'><label class='col-sm-3 control-label no-padding-right' for='txtNewPwd1'>新密码</label><div class='col-sm-9'><input type='text' onfocus=\"this.type='password'\" id='txtNewPwd1' placeholder='请输入新密码' class='col-xs-10 col-sm-5' /></div></div><div class='space-4'></div><div class='form-group'><label class='col-sm-3 control-label no-padding-right' for='txtNewPwd2'>确认新密码</label><div class='col-sm-9'><input type='text' onfocus=\"this.type='password'\" id='txtNewPwd2' placeholder='再次输入新密码' class='col-xs-10 col-sm-5' /></div></div></form></div>",
        buttons : {
            "success" : {
                "label" : "<i class='icon-ok'></i> 保存",
                "className" : "btn-sm btn-success",
                "callback" : function() {
                    var txt1 = $("#txtOldPwd").val();
                    var txt2 = $("#txtNewPwd1").val();
                    var txt3 = $("#txtNewPwd2").val();

                    if(txt1 == "" || txt2 == "" || txt3 == ""){
                        bootbox.alert("密码不能为空");
                        return false;
                    }
                    if(txt2 != txt3 ){
                        bootbox.alert("两次输入新密码不一致，请重新输入!");
                        return false;
                    }
                    var info = {"oldpwd":txt1,"newpwd1":txt2,"newpwd2":txt3,"userid":uid};
                    $.post("api.php?method=changepwd",info,function(data){
                        if(data.return_code=="0")
                        {
                            bootbox.alert("密码更新成功,请重新登录",function () {
                                location.href="api.php?method=logout";
                            });
                        }
                        else
                        {
                            if(data.return_code=="-4")
                            {
                                bootbox.alert("旧密码输入错误",function () {
                                    //location.href="api.php?method=logout";
                                });
                                return false;
                            }
                            else if(data.return_code=="-1")
                            {
                                bootbox.alert("服务器错误");
                                return false;
                            }

                        }

                    },'json');
                }
            },
            "cancel" : {
                "label" : "<i class='icon-info'></i> 取消",
                "className" : "btn-sm btn-danger",
                "callback" : function() { }
            }
        }
    });
}

function inputpwdtogo(uid,gowh)
{
    bootbox.dialog({
        title : "需要认证",
        message : "<div class='well ' style='margin-top:25px;'><form class='form-horizontal' role='form'><div class='form-group'><label class='col-sm-3 control-label no-padding-right' for='txtOldPwd'>密码</label><div class='col-sm-9'><input type='text' onfocus=\"this.type='password'\" id='txtOldPwd' placeholder='请输入密码' class='col-xs-10 col-sm-5' autocomplete='off'/></div></div><div class='space-4'></div></form></div>",
        buttons : {
            "success" : {
                "label" : "<i class='icon-ok'></i> OK",
                "className" : "btn-sm btn-success",
                "callback" : function() {
                    var txt1 = $("#txtOldPwd").val();


                    if(txt1 == ""){
                        bootbox.alert("密码不能为空");
                        return false;
                    }
                    
                    var info = {"oldpwd":txt1,"userid":uid};
                    $.post("api.php?method=checkpwd",info,function(data){
                        if(data.return_code=="0")
                        {
                            bootbox.alert("验证通过",function () {
                                location.href=gowh; //防君子不防。。。
                            });
                        }
                        else
                        {
                            if(data.return_code=="-4")
                            {
                                bootbox.alert("密码输入错误",function () {
                                    //location.href="api.php?method=logout";
                                });
                                return false;
                            }
                            else if(data.return_code=="-1")
                            {
                                bootbox.alert("服务器错误");
                                return false;
                            }

                        }

                    },'json');
                }
            },
            "cancel" : {
                "label" : "<i class='icon-info'></i> 取消",
                "className" : "btn-sm btn-danger",
                "callback" : function() { }
            }
        }
    });
}


function changeStyle(theid,classname) {
  var obj = document.getElementById(theid);
  //obj.className = "style2";
  obj.setAttribute("class", classname);
}